from screeninfo import get_monitors

monitor = get_monitors()[0]
width = monitor.width
height = monitor.height

with open("w.cfg", "w") as file :
    file.write(str(width))

with open("h.cfg", "w") as file :
    file.write(str(height))